import axios from "axios";
var chart_edc0db84a201493da0749f2c3b80156c = echarts.init(
    document.getElementById('edc0db84a201493da0749f2c3b80156c'), 'white', { renderer: 'canvas' });
var option_edc0db84a201493da0749f2c3b80156c = {
    "animation": true,
    "animationThreshold": 2000,
    "animationDuration": 1000,
    "animationEasing": "cubicOut",
    "animationDelay": 0,
    "animationDurationUpdate": 300,
    "animationEasingUpdate": "cubicOut",
    "animationDelayUpdate": 0,
    "color": [
        "#c23531",
        "#2f4554",
        "#61a0a8",
        "#d48265",
        "#749f83",
        "#ca8622",
        "#bda29a",
        "#6e7074",
        "#546570",
        "#c4ccd3",
        "#f05b72",
        "#ef5b9c",
        "#f47920",
        "#905a3d",
        "#fab27b",
        "#2a5caa",
        "#444693",
        "#726930",
        "#b2d235",
        "#6d8346",
        "#ac6767",
        "#1d953f",
        "#6950a1",
        "#918597"
    ],
    "series": [
        {
            "type": "map",
            "label": {
                "show": false,
                "position": "top",
                "margin": 8
            },
            "mapType": "china-cities",
            "data": [
                {
                    "name": "\u5317\u4eac",
                    "value": 50
                },
                {
                    "name": "\u4e0a\u6d77",
                    "value": 39
                },
                {
                    "name": "\u6df1\u5733",
                    "value": 27
                },
                {
                    "name": "\u676d\u5dde",
                    "value": 21
                },
                {
                    "name": "\u5e7f\u5dde",
                    "value": 18
                },
                {
                    "name": "\u5357\u4eac",
                    "value": 15
                },
                {
                    "name": "\u53a6\u95e8",
                    "value": 9
                },
                {
                    "name": "\u5408\u80a5",
                    "value": 8
                },
                {
                    "name": "\u6210\u90fd",
                    "value": 8
                },
                {
                    "name": "\u6b66\u6c49",
                    "value": 7
                },
                {
                    "name": "\u798f\u5dde",
                    "value": 6
                },
                {
                    "name": "\u957f\u6c99",
                    "value": 6
                },
                {
                    "name": "\u897f\u5b89",
                    "value": 4
                },
                {
                    "name": "\u592a\u539f",
                    "value": 4
                },
                {
                    "name": "\u90d1\u5dde",
                    "value": 4
                },
                {
                    "name": "\u5929\u6d25",
                    "value": 4
                },
                {
                    "name": "\u5357\u5b81",
                    "value": 3
                },
                {
                    "name": "\u6d4e\u5357",
                    "value": 3
                },
                {
                    "name": "\u6c88\u9633",
                    "value": 3
                },
                {
                    "name": "\u4f5b\u5c71",
                    "value": 3
                },
                {
                    "name": "\u54c8\u5c14\u6ee8",
                    "value": 3
                },
                {
                    "name": "\u4e1c\u839e",
                    "value": 3
                },
                {
                    "name": "\u5927\u8fde",
                    "value": 2
                },
                {
                    "name": "\u547c\u548c\u6d69\u7279",
                    "value": 2
                },
                {
                    "name": "\u4e2d\u5c71",
                    "value": 2
                },
                {
                    "name": "\u6606\u660e",
                    "value": 2
                },
                {
                    "name": "\u82cf\u5dde",
                    "value": 2
                },
                {
                    "name": "\u4e34\u6c82",
                    "value": 1
                },
                {
                    "name": "\u54b8\u9633",
                    "value": 1
                },
                {
                    "name": "\u4fdd\u5b9a",
                    "value": 1
                },
                {
                    "name": "\u4e91\u6d6e",
                    "value": 1
                },
                {
                    "name": "\u5609\u5174",
                    "value": 1
                },
                {
                    "name": "\u535a\u5c14\u5854\u62c9\u8499\u53e4\u81ea\u6cbb\u5dde",
                    "value": 1
                },
                {
                    "name": "\u9a6c\u978d\u5c71",
                    "value": 1
                },
                {
                    "name": "\u5b81\u6ce2",
                    "value": 1
                },
                {
                    "name": "\u5b9c\u6625",
                    "value": 1
                },
                {
                    "name": "\u957f\u6625",
                    "value": 1
                },
                {
                    "name": "\u94f6\u5ddd",
                    "value": 1
                },
                {
                    "name": "\u91cd\u5e86",
                    "value": 1
                },
                {
                    "name": "\u8302\u540d",
                    "value": 1
                },
                {
                    "name": "\u829c\u6e56",
                    "value": 1
                },
                {
                    "name": "\u821f\u5c71",
                    "value": 1
                },
                {
                    "name": "\u77f3\u5bb6\u5e84",
                    "value": 1
                },
                {
                    "name": "\u6e56\u5dde",
                    "value": 1
                },
                {
                    "name": "\u6e05\u8fdc",
                    "value": 1
                },
                {
                    "name": "\u6dc4\u535a",
                    "value": 1
                },
                {
                    "name": "\u6c5f\u95e8",
                    "value": 1
                },
                {
                    "name": "\u65e0\u9521",
                    "value": 1
                },
                {
                    "name": "\u627f\u5fb7",
                    "value": 1
                },
                {
                    "name": "\u9752\u5c9b",
                    "value": 1
                },
                {
                    "name": "\u60e0\u5dde",
                    "value": 1
                },
                {
                    "name": "\u4e09\u4e9a",
                    "value": 1
                }
            ],
            "roam": true,
            "aspectScale": 0.75,
            "nameProperty": "name",
            "selectedMode": false,
            "zoom": 1,
            "mapValueCalculation": "sum",
            "showLegendSymbol": false,
            "itemStyle": {
                "normal": {
                    "areaColor": "rgba(255,255,255, 0.05)",
                    "borderColor": "#56a2dc"
                },
                "emphasis": {
                    "areaColor": "rgba(180,180,180, 0.8)"
                }
            },
            "emphasis": {}
        }
    ],
    "legend": [
        {
            "data": [
                ""
            ],
            "selected": {
                "": true
            },
            "show": true,
            "padding": 5,
            "itemGap": 10,
            "itemWidth": 25,
            "itemHeight": 14
        }
    ],
    "tooltip": {
        "show": true,
        "trigger": "item",
        "triggerOn": "mousemove|click",
        "axisPointer": {
            "type": "line"
        },
        "showContent": true,
        "alwaysShowContent": false,
        "showDelay": 0,
        "hideDelay": 100,
        "textStyle": {
            "fontSize": 14
        },
        "borderWidth": 0,
        "padding": 5
    },
    "title": [
        {
            "padding": 5,
            "itemGap": 10
        }
    ],
    "visualMap": {
        "show": false,
        "type": "continuous",
        "min": 0,
        "max": 50,
        "inRange": {
            "color": [
                "#3d81a0",
                "#00FFFF"
            ]
        },
        "calculable": true,
        "inverse": false,
        "splitNumber": 5,
        "orient": "vertical",
        "showLabel": true,
        "itemWidth": 20,
        "itemHeight": 140,
        "borderWidth": 0
    }
};
chart_edc0db84a201493da0749f2c3b80156c.setOption(option_edc0db84a201493da0749f2c3b80156c);
window.addEventListener('resize', function () {
    chart_edc0db84a201493da0749f2c3b80156c.resize();
})

export const getMapData = (city) => {
    axios
        .get(city + '/districtCount' )
        .then(function (response) {
            option_edc0db84a201493da0749f2c3b80156c.series[0].data = response.data
            option_edc0db84a201493da0749f2c3b80156c.series[0].mapType = city

            chart_edc0db84a201493da0749f2c3b80156c.setOption(option_edc0db84a201493da0749f2c3b80156c);
            window.addEventListener('resize', function () {
                chart_edc0db84a201493da0749f2c3b80156c.resize();
            })
        })
        .catch(function (error) { // 请求失败处理
            console.log(error);
        })
}
